import {getEnum} from "@/api/modules/global";
import util from "@/utils/util";

const enumData = Vue => {
  return new Promise((resolve,reject) => {
    getEnum().then(
      res => {
        var data = res.data;
        var enumData = {};
        for (var key in data) {
          var items = [];
          for (var code in data[key]) {
            items.push(data[key][code]);
          }
          /*枚举排序*/
          items = items.sort(function (a, b) {
            return a.code - b.code;
          });
          enumData[key + "_dict"] = items;
          enumData[key + "_map"] = util.toMap(items, "code");
          enumData[key + "_key_map"] = util.toMap(items, "key");
        }
        resolve(enumData)
      }
    )
  })
}
export default enumData
